package com.example.dc.mapper;

import com.example.dc.domain.AnwserKeyword;
import com.example.dc.domain.Question;
import com.example.dc.domain.Reply;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface QuestionMapper {

    //随机抽取问题
    public Question getRandomQuestion(@Param("userId") Integer userId);



    //查询问题的所有答案关键词
    @Select("select * from d_anwser_keyword where question_id=#{id} and status='1' ")
    public List<AnwserKeyword> getAnwserKeyword(@Param("id") Integer id);

    //更新答案关键词匹配表
    @Update("update d_anwser_keyword set hotness=hotness+1,recent_call=NOW() where id=#{id}")
    public void updateAnwserKeyword(@Param("id") Integer id);

    //插入用户回答内容
    public Integer insertUserReply(Reply reply);

    //更新用户打分表
    @Insert("insert into d_health_score (personal_question_id,keyword_id,user_id,reply_id,chatgpt) values (#{personalQuestionId},#{keywordId},#{userId},#{replyId},#{chatgpt});")
    public void insertUserScore(@Param("personalQuestionId") Integer personalQuestionId,@Param("keywordId") Integer keywordId,@Param("userId") Integer userId,@Param("replyId") Integer replyId,@Param("chatgpt") String chatgpt);

    @Select("select * from d_question where grade=3")
    public List<Question> getThreeStander();


}
